#
#  rb_main.rb
#  SpaceTrader
#
#  Created by Jon Wood on 22/11/2007.
#  Copyright (c) 2007 __MyCompanyName__. All rights reserved.
#

require 'osx/cocoa'
require 'logger'
require 'lib/macos/cocoa_logger'

class Logger
  def format_message(severity, timestamp, progname, msg)
    "#{severity}: #{msg}\n" 
  end
end

if $0 == __FILE__ then
  LOGGER = Logger.new(CocoaLogger.new)
  LOGGER.log(Logger::INFO, "Starting Space Trader")
  
  basePath = OSX::NSBundle.mainBundle.resourcePath.fileSystemRepresentation
  $: << "#{basePath}/lib/"
  Dir["#{basePath}/**/*.rb"].each do |f|
    LOGGER.log(Logger::DEBUG, "Loading #{f}")
    require f
  end
  
  # App configuration
  GameObject.load_path = basePath + "/data/objects"
  LOGGER.log(Logger::DEBUG, "Load path set to #{GameObject.load_path}")
  
  OSX.NSApplicationMain(0, nil)
end
